//
// Created by Tony on 2024/5/18.
//

#ifndef LEXER_TOKEN_QUEUE_H
#define LEXER_TOKEN_QUEUE_H

#include "token/Token.h"
#include <memory>
#include <vector>

namespace Lexer {

using std::shared_ptr;
using std::vector;

class TokenQueue {
    vector<shared_ptr<Token>> tokens;
    size_t cursor{};
    Position lastPosition{};

public:
    TokenQueue() = default;

    void offer(const shared_ptr<Token>& token) { tokens.push_back(token); }

    /**
     * @return null_ptr: token queue is empty
     */
    shared_ptr<Token> peek(size_t offet = 0);

    /**
     * @return null_ptr: token queue is empty
     */
    shared_ptr<Token> poll();

    size_t size() const { return tokens.size(); }

    void append(const shared_ptr<TokenQueue>& other);

    Position getLastPosition() const { return lastPosition; }
};

} // namespace Lexer

#endif // LEXER_TOKEN_QUEUE_H
